﻿#region NeoPatterns
// 
// NeoPatterns framework is released under LGPLv3 license.
// See http://www.opensource.org/licenses/lgpl-3.0.html for more details.
// 
// Please visit http://neopatterns.wikidot.com for more information about NeoPatterns
// 
// Copyright (c) Pascal Craponne 2008
// 
#endregion

using System;
using System.Runtime.Serialization;
using System.Security.Permissions;

namespace NeoPatterns.Exception
{
    /// <summary>
    /// All IObjectRegistry related exceptions inherit from here
    /// </summary>
    [Serializable]
    public class RegistryException : NeoPatternsException
    {
        public string Value { get; private set; }

        public RegistryException()
        {
        }

        public RegistryException(string value)
        {
            Value = value;
        }

        public RegistryException(string message, System.Exception innerException)
            : base(message, innerException)
        {
        }

        [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
        public override void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            info.AddValue("Value", Value);
            base.GetObjectData(info, context);
        }

        protected RegistryException(SerializationInfo serializationInfo, StreamingContext streamingContext)
            : base(serializationInfo, streamingContext)
        {
            Value = serializationInfo.GetString("Value");
        }
    }
}